<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>维修费用表</title>
		<meta name="keywords" content="Bootstrap模版,Bootstrap模版下载,Bootstrap教程,Bootstrap中文" />
		<meta name="description" content="站长素材提供Bootstrap模版,Bootstrap教程,Bootstrap中文翻译等相关Bootstrap插件下载" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<!-- basic styles -->

		<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="assets/css/font-awesome.min.css" />
        <link rel="stylesheet"  href="assets/css/kkpager_orange.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->

		<!-- ace styles -->

		<link rel="stylesheet" href="assets/css/ace.min.css" />
		<link rel="stylesheet" href="assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="assets/css/ace-skins.min.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->

		<script src="assets/js/ace-extra.min.js"></script>

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="assets/js/html5shiv.js"></script>
		<script src="assets/js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body>
		<#include "header.ftl"/>

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>
				<#include "left_list_menu.ftl">
				<div class="main-content">
					<div class="breadcrumbs" id="breadcrumbs">
						<script type="text/javascript">
							try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
						</script>

						<ul class="breadcrumb">
							<li>
								<i class="icon-home home-icon"></i>
								产品管理
							</li>

							<li>
								维修费用列表
							</li>
						</ul><!-- .breadcrumb -->

					</div>

					<div class="page-content">
						<div class="page-header">
							<#--<h1>-->
								<#--客户信息列表-->
								<#--<small>-->
									<#--<i class="icon-double-angle-right"></i>-->
									<#--Static &amp; Dynamic Tables-->
								<#--</small>-->
							<#--</h1>-->
                                <input type="text" name="min_price_key" id="min_price_key" placeholder="请输入最小价格" value="<#if maintainListView.min_price??>${maintainListView.min_price?c}</#if>"/>
                                <input type="text" name="max_price_key" id="max_price_key" placeholder="请输入最大价格" value="<#if maintainListView.max_price??>${maintainListView.max_price?c}</#if>"/>

                                <select id="search_service_kind">
                                    <option value="0">全部</option>
                                    <#if maintainListView.service_kind == 1>
                                        <option value="1" selected="selected">空调</option>
                                    <#else >
                                        <option value="1" >空调</option>
                                    </#if>
                                    <#if maintainListView.service_kind == 2>
                                        <option value="2" selected="selected">地暖</option>
                                    <#else >
                                        <option value="2" >地暖</option>
                                    </#if>
                                    <#if maintainListView.service_kind == 3>
                                        <option value="3" selected="selected">新风</option>
                                    <#else >
                                        <option value="3" >新风</option>
                                    </#if>
                                    <#if maintainListView.service_kind == 4>
                                        <option value="4" selected="selected">水处理</option>
                                    <#else >
                                        <option value="4" >水处理</option>
                                    </#if>
                                    <#if maintainListView.service_kind == 5>
                                        <option value="5" selected="selected">生活热水</option>
                                    <#else >
                                        <option value="5" >生活热水</option>
                                    </#if>
                                    <#if maintainListView.service_kind == 6>
                                        <option value="6" selected="selected">智能家居</option>
                                    <#else >
                                        <option value="6" >智能家居</option>
                                    </#if>
                                </select>
                                <#--<button id="search_customer" type="button" class="btn btn-sm btn-primary">-->
                                    <#--<i class="icon-search"></i>-->
                                    <#--搜索-->
                                <#--</button>-->
                                <button id= "search_maintain" type="button" class="btn btn-primary btn-sm" >搜索</button>
                                    <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#addMaintain" style="float: right;">添加维修价格</button>
						</div><!-- /.page-header -->

                        <!-- 添加管理员 -->
                        <div class="modal fade" id="addMaintain" data-backdrop="static" data-keyboard="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal">
                                            <span>&times;</span>
                                        </button>
                                        <h4 class="modal-title"> 添加维修价格</h4>
                                    </div>
                                    <div class="modal-body">
                                        <form id="addMaintainForm" role="form" class="form-horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">维修名称 :</label>
                                                <div class="col-sm-6">
                                                    <input type="text" name="service_name" class="form-control" />
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">内容 :</label>
                                                <div class="col-sm-6">
                                                    <input type="text" name="service_content" class="form-control" />
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">价格 :</label>
                                                <div class="col-sm-6">
                                                    <input type="text" name="service_all_price" class="form-control" />
                                                </div>
                                                <p class="form-control-static col-sm-1" style="color:red">*</p>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">分类 :</label>
                                                <div class="col-sm-6">
                                                    <select id="service_kind_key">
														<option value="0">请选择</option>
														<option value="1">空调</option>
														<option value="2">地暖</option>
														<option value="3">新风</option>
														<option value="4">生活热水</option>
														<option value="5">水处理</option>
														<option value="6">智能家居</option>
													</select>
                                                </div>
                                                <p class="form-control-static col-sm-1" style="color:red">*</p>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-3 control-label">备注 :</label>
                                                <div class="col-sm-6">
                                                    <input type="text" name="service_back" class="form-control" />
                                                </div>
                                                <p class="form-control-static col-sm-1" style="color:red">*</p>
                                            </div>
                                        </form>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-primary btn-sm"  id="addMaintainBtn">保存</button>
                                    </div>
                                </div>
                            </div>
                        </div>


						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
								<div class="row">
									<div class="col-xs-12">
										<div class="table-responsive">
											<table id="sample-table-1" class="table table-striped table-bordered table-hover">
												<thead>
													<tr>
														<th>编号</th>
                                                        <th>维修名称</th>
														<th>内容</th>
														<th class="hidden-480">价格</th>
														<th>分类</th>
														<th class="hidden-480">维修描述</th>
														<th>操作</th>
													</tr>
												</thead>

												<tbody>
													<#list serviceProjects as list>
														<tr>
															<td>${list.service_id}</td>
                                                            <td>${list.service_name !""}</td>
															<td>${list.service_content !""}</td>
															<td>${list.service_all_price !""}</td>
															<td>
																<#if list.service_kind == 1>
																	空调
																    <#elseif list.service_kind == 2>
																	地暖
																<#elseif list.service_kind == 3>
                                                                    新风
																<#elseif list.service_kind == 4>
                                                                    生活热水
																<#elseif list.service_kind == 5>
                                                                    水处理
																<#elseif list.service_kind == 6>
                                                                    智能家居
																</#if>
															</td>
                                                            <td>${list.service_back !""}</td>
															<td>
																<div class="vis ible-md visible-lg hidden-sm hidden-xs btn-group">
																	<button class="btn btn-xs btn-info" style="color: #1a1a1a" onclick="updateMaintain('${list.service_id?c}','${list.service_name}','${list.service_content}',
																			'${list.service_all_price}','${list.service_back}',${list.service_kind?c})">编辑</button>
																	<button class="btn btn-xs btn-danger" style="color: #1a1a1a" onclick="deleteThis(${list.service_id?c},'deleteProject')">删除</button>
																</div>
																<div class="visible-xs visible-sm hidden-md hidden-lg">
																	<div class="inline position-relative">
																		<button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown">
																			<i class="icon-cog icon-only bigger-110"></i>
																		</button>

																		<ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">
																			<li>
																				<a href="#" class="tooltip-info" data-rel="tooltip" title="View">
																					<span class="blue">
																						<i class="icon-zoom-in bigger-120"></i>
																					</span>
																				</a>
																			</li>

																			<li>
																				<a href="#" class="tooltip-success" data-rel="tooltip" title="Edit">
																					<span class="green">
																						<i class="icon-edit bigger-120"></i>
																					</span>
																				</a>
																			</li>

																			<li>
																				<a href="#" class="tooltip-error" data-rel="tooltip" title="Delete">
																					<span class="red">
																						<i class="icon-trash bigger-120"></i>
																					</span>
																				</a>
																			</li>
																		</ul>
																	</div>
																</div>
															</td>
														</tr>
													</#list>
												</tbody>
											</table>
                                            <div class="modal-footer no-margin-top">
                                                <div id="kkpager"></div>
                                            </div>
										</div><!-- /.table-responsive -->
									</div><!-- /span -->
								</div><!-- /row -->

								<div class="hr hr-18 dotted hr-double"></div>
							</div><!-- /.col -->
						</div><!-- /.row -->
					</div><!-- /.page-content -->
				</div><!-- /.main-content -->


                <!-- 编辑维修费用信息 -->
                <div class="modal fade" id="editMaintain">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close">
                                    <span aria-hidden="true" data-dismiss="modal">&times;</span><span class="sr-only">close</span>
                                </button>
                                <h4 class="modal-title">修改维修费</h4>
                            </div>
                            <div class="modal-body">
                                <form role="form" id="editAdminInfoForm" class="form-horizontal">
                                    <input type="text" class="form-control" id="project_id" name="project_id" placeholder="" style="display: none">
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">维修名称</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" id="project_name" name="project_name" placeholder="">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">内容</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" id="project_content" name="project_content" placeholder="">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">价格</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" id="project_price" name="project_price"  placeholder="">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">分类</label>
                                        <div class="col-sm-4">
                                            <select id="service_kind">
                                                <option value="0">请选择</option>
                                                <option value="1">空调</option>
                                                <option value="2">地暖</option>
                                                <option value="3">新风</option>
                                                <option value="4">生活热水</option>
                                                <option value="5">水处理</option>
                                                <option value="6">智能家居</option>
											</select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">维修描述</label>
                                        <div class="col-sm-4">
											<textarea rows=7 cols="40" placeholder="请输入描述" id="project_back" name="project_back"></textarea>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-primary btn-sm" id="saveEditMaintainForm">保存</button>
                            </div>
                        </div>
                    </div>
                </div>

			</div><!-- /.main-container-inner -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<!-- basic scripts -->


		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
        <script type="text/javascript" src="assets/js/jquery-1.10.2.min.js"></script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/typeahead-bs2.min.js"></script>

		<!-- page specific plugin scripts -->

		<script src="assets/js/jquery.dataTables.min.js"></script>
		<script src="assets/js/jquery.dataTables.bootstrap.js"></script>

		<!-- ace scripts -->

		<script src="assets/js/ace-elements.min.js"></script>
		<script src="assets/js/ace.min.js"></script>

        <script type="text/javascript" src="assets/js/kkpager.min.js"></script>
        <script src="assets/js/myJs.js"></script>

		<!-- inline scripts related to this page -->

        <script src="assets/js/jquery.cookie.js"></script>
        <script type="text/javascript">
            window.onload=function(){
                var name = $.cookie('username');
                if (name == '' || name == null || typeof(name)=="undefined"){
                    document.getElementById("user_name").innerText="unknown user";
                    alert("请先登录");
                    window.location.href='login';
                }

                document.getElementById("user_name").innerText=name;
            }


            $(function(){
                //生成分页
                //有些参数是可选的，比如lang，若不传有默认值
                kkpager.generPageHtml({
                    pno : '${pageInfo.page_index}',
                    //总页码
                    total : '${pageInfo.page_count}',
                    //总数据条数
                    totalRecords : '${pageInfo.count_info}',
                    mode : 'click',//默认值是link，可选link或者click
                    click : function(n){
                        // do something
                        window.location.href = '${pageInfo.page_href}'+ n;
                        //手动选中按钮
                        this.selectPage(n);
                        return false;
                    }
                });
            });

            $("#search_maintain").click(function(){
                var max_price = $("input[name='max_price_key']").val();
                var min_price = $("input[name='min_price_key']").val();
                var service_kind = $("#search_service_kind").val();

                var start_href = "selectMaintainList?page=1&service_kind="+service_kind;
                if(null != max_price && "" != max_price){
                    start_href = start_href+"&max_price="+max_price;
                }
                if(null != min_price && "" != min_price){
                    start_href = start_href+"&min_price="+min_price;
                }
                window.location.href = start_href;
            });

            //添加维修价格
            $("#addMaintainBtn").click(function(){
                var admin_name = $("input[name='service_content']").val();
                var admin_phone = $("input[name='service_all_price']").val();
                var user_login_name = $("input[name='service_back']").val();
                var service_kind = $("#service_kind_key").val();
                var service_name = $("input[name='service_name']").val();
                if(service_kind == 0){
                    alert("请选择分类");
                    return false;
				}
                if(admin_name == ""){
                    alert("请输入内容");
                    return false;
                }
                if(admin_phone == ""){
                    alert("请输入价格");
                    return false;
                }
                if(user_login_name == ""){
                    alert("请输入说明备注");
                    return false;
                }
                if(service_name == ""){
                    alert("请输入维修名称");
                    return false;
                }
                var c = $("#addMaintainForm").serialize();
                debugger;
                //return false;
                $.ajax({
                    type:"POST",
                    url:"insertMaintain?",
                    data:{"service_name":service_name,"service_content":admin_name,"service_all_price":admin_phone,"service_back":user_login_name,"service_kind":service_kind},
                    dataType:'json',
                    beforeSend: function () {
//                        initial_deal();
                    },
                    success:function(data){
//                        closeWaitDialog();
                        if(data.status == 200){
                            alert("添加成功！");
                            window.location.reload();
                        }else{
                            alert(data.info);
                            return false;
                        }
                    },
                    error: function () {
//                        closeWaitDialog();
                        alert("服务端出错！");
                        return false;
                    }
                });
            });


            $("#saveEditMaintainForm").click(function(){

                var admin_id = $("#project_id").val();
                var admin_name = $("#project_content").val();
                var admin_phone = $("#project_price").val();
                var admin_login_name = $("#project_back").val();
                var service_kind = $("#service_kind").val();
                var service_name = $("#project_name").val();

                if(admin_name == null || admin_name == ''){
                    alert("维修内容不能为空!");
                    return false;
                }
                if(admin_phone == null || admin_phone == ''){
                    alert("价格不能为空!");
                    return false;
                }
                if(admin_login_name == null || admin_login_name == ''){
                    alert("备注不能为空!");
                    return false;
                }
                if(service_kind == null || service_kind == ''){
                    alert("请选择分类!");
                    return false;
                }
                if(service_name == null || service_name == ''){
                    alert("维修名称不能为空!");
                    return false;
                }

                $.ajax({
                    type:"POST",
                    url:"updateMaintain?",
                    data:{"service_id":admin_id,"service_name":service_name,"service_content":admin_name,"service_all_price":admin_phone,"service_back":admin_login_name,"service_kind":service_kind},
                    dataType:'json',
                    beforeSend: function () {
//                        initial_deal();
                    },
                    success:function(data){
//                        closeWaitDialog();
                        if(data.status == 200){
                            alert("修改成功！");
                            window.location.reload();
                        }else{
                            alert(data.info);
                            return false;
                        }
                    },
                    error: function () {
//                        closeWaitDialog();
                        alert("服务端出错！");
                        return false;
                    }
                });
            });

			jQuery(function($) {
				var oTable1 = $('#sample-table-2').dataTable( {
				"aoColumns": [
			      { "bSortable": false },
			      null, null,null, null, null,
				  { "bSortable": false }
				] } );
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
			
			
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			})
		</script>
<#--<script type="text/javascript">-->
<#--var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");-->
<#--document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fe9e1d61340ff3d9495a8cca04ebdb49d' type='text/javascript'%3E%3C/script%3E"));-->
<#--</script>-->
<#--<a href="http://www.iteblog.com">过往记忆</a>-->
</body>
</html>
